package cz.myslivec.knihovna.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;

import cz.myslivec.knihovna.entity.BookCopy;
import cz.myslivec.knihovna.entity.Title;

@Name("titleDaoImpl")
@AutoCreate
public class TitleDaoImpl implements TitleDao {

	@In
	private EntityManager entityManager;

	
	public void create(Title title) {
		entityManager.persist(title);
	}

	public void delete(Title title) {
		entityManager.remove(title);
	}

	public void update(Title title) {
		entityManager.merge(title);
	}

	public Title getTitle(long id) {
		// TODO Auto-generated method stub
		return null;
	}

	public Title findByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@SuppressWarnings("unchecked")
	public List<Title> list() {
		Query query = entityManager.createQuery("from Title");
		return (List<Title>)query.getResultList();
	}

	public void addBookCopy(BookCopy copy) {
		// TODO Auto-generated method stub
	}

}
